<template>
    <view>
        <view @tap="yczz" class="sq_screen"></view>
        <view class="sq_box">
            <view class="sq_title">需要您的授权</view>
            <view class="sq_title1">为了提供更好的服务</view>
            <view class="sq_title1">请在稍后的提示框中点击“允许”</view>
            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/sqimg.png"></image>
            <view style="width: 100%; display: flex; justify-content: space-around; align-items: center">
                <view @tap="qx" class="btn_no">取消</view>
                <button @tap="bindGetUserInfo" class="btn_ok" :style="'background:' + color">确认</button>
            </view>
        </view>
    </view>
</template>

<script>
import cardlist from '@/ymq_canyino2o/dist/cardlist/index';
import gettel from '@/ymq_canyino2o/dist/gettel/index';
var app = getApp();
export default {
    components: {
        cardlist,
        gettel
    },
    data() {
        return {
            userinfo: '',
            color: ''
        };
    },
    onLoad: function (n) {
        app.globalData.setNavigationBarColor(this);
    },
    onReady: function () {},
    onShow: function () {},
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {},
    onShareAppMessage: function () {},
    methods: {
        bindGetUserInfo: function (n) {
            var o = getCurrentPages();
            uni.showLoading({
                title: '登录中...',
                mask: true
            });
            uni.getUserProfile({
                desc: '用于完善会员资料',
                success: (res) => {
                    app.globalData.util.request({
                        url: 'entry/wxapp/login',
                        cachetime: '0',
                        data: {
                            openid: getApp().globalData.getOpenId,
                            img: res.userInfo.avatarUrl,
                            name: res.userInfo.nickName
                        },
                        header: {
                            'content-type': 'application/json'
                        },
                        dataType: 'json',
                        success: function (n) {
                            console.log('用户信息', n);
                            app.globalData.userInfo = n.data;
                            if (1 < o.length) {
                                o[o.length - 2].setData({
                                    userinfo: n.data
                                });
                            }
                            setTimeout(function () {
                                uni.navigateBack({});
                            }, 1000);
                        }
                    });
                }
            });

            /*     
    console.log(n);
    var o = getCurrentPages();
         console.log(o), "getUserInfo:ok" == n.detail.errMsg && (wx.showLoading({
             title: "登录中...",
             mask: !0
         }), wx.getUserInfo({
             success: function(n) {
                 console.log(n), a.util.request({
                     url: "entry/wxapp/login",
                     cachetime: "0",
                     data: {
                         openid: getApp().getOpenId,
                         img: n.userInfo.avatarUrl,
                         name: n.userInfo.nickName
                     },
                     header: {
                         "content-type": "application/json"
                     },
                     dataType: "json",
                     success: function(n) {
                         (console.log("用户信息", n), a.globalData.userInfo = n.data, 1 < o.length) && o[o.length - 2].setData({
                             userinfo: n.data
                         });
                         setTimeout(function() {
                             wx.navigateBack({});
                         }, 1e3);
                     }
                 });
             }
         }));*/
        },

        qx: function () {
            uni.navigateBack({});
        },

        yczz() {
            console.log('占位：函数 yczz 未声明');
        }
    }
};
</script>
<style>
@import './getdl.css';
</style>
